import 'package:flutter/material.dart';
import 'package:xiongan_app_yy/widgets/comm/left_icon_widget.dart';

class DeploymentDetailsInfoList extends StatefulWidget {
  final Map<String, dynamic> args;

  DeploymentDetailsInfoList(this.args);

  @override
  _DeploymentDetailsInfoListState createState() =>
      _DeploymentDetailsInfoListState();
}

class _DeploymentDetailsInfoListState extends State<DeploymentDetailsInfoList> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          elevation: 0,
          centerTitle: true,
          title: Text("物资明细", style: TextStyle(fontSize: 18)),
          leading: LeftIconWidget(icon: Icons.chevron_left, isize: 36),
        ),
        backgroundColor: Color(0xf4f4f4f4),
        body: ListView.separated(
            itemBuilder: (BuildContext context, int index) {
              return DeliveryItemDetails();
            },
            separatorBuilder: (BuildContext context, int index) =>
                Divider(height: 1, color: Color(0xffdddddd)),
            itemCount: 6));
  }
}

class DeliveryItemDetails extends StatefulWidget {
  @override
  _DeliveryItemDetailsState createState() => _DeliveryItemDetailsState();
}

class _DeliveryItemDetailsState extends State<DeliveryItemDetails> {
  int num = 0;

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: ConstrainedBox(
        constraints: BoxConstraints.expand(width: double.infinity, height: 172),
        child: Stack(
          children: <Widget>[
            Positioned(
              top: 16,
              left: 20,
              width: 100,
              height: 100,
              child: Image.asset(
                "assets/images/real_background.png",
                fit: BoxFit.fill,
              ),
            ),
            Positioned(
              child: Text(
                "ConCab Kabel 电缆",
                style: TextStyle(
                  color: Color(0xff646464),
                  fontSize: 16,
                ),
              ),
              left: 132,
              top: 12,
            ),
            Positioned(
              child: Text(
                "物资编码：3643434",
                style: TextStyle(
                  color: Color(0xff646464),
                  fontSize: 16,
                ),
              ),
              left: 132,
              top: 40,
            ),
            Positioned(
              child: Text(
                "型号：20*20",
                style: TextStyle(
                  color: Color(0xff646464),
                  fontSize: 16,
                ),
              ),
              left: 132,
              top: 68,
            ),
            Positioned(
              child: Text(
                "规格：65434",
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                  color: Color(0xff646464),
                  fontSize: 16,
                ),
              ),
              right: 20,
              top: 68,
            ),
            Positioned(
              child: Text(
                "计划数量：20",
                style: TextStyle(
                  color: Color(0xff646464),
                  fontSize: 16,
                ),
              ),
              left: 132,
              top: 96,
            ),
            Positioned(
              child: Text(
                "基本单位：件",
                style: TextStyle(
                  color: Color(0xff646464),
                  fontSize: 16,
                ),
              ),
              right: 20,
              top: 96,
            ),
            Positioned(
              child: Text(
                "实际数量：",
                style: TextStyle(
                  color: Color(0xff646464),
                  fontSize: 16,
                ),
              ),
              left: 20,
              top: 128,
            ),
            Positioned(
              child: GestureDetector(
                onTap: () {
                  setState(() {
                    num++;
                  });
                },
                child: Text(
                  "+",
                  style: TextStyle(
                    color: Color(0xff646464),
                    fontSize: 16,
                  ),
                ),
              ),
              right: 20,
              top: 130,
            ),
            Positioned(
              child: Text(
                "${num}",
                style: TextStyle(
                  color: Color(0xff323232),
                  fontSize: 18,
                ),
              ),
              right: 40,
              top: 128,
            ),
            Positioned(
              child: GestureDetector(
                onTap: () {
                  setState(() {
                    num = num == 0 ? 0 : num--;
                  });
                },
                child: Text(
                  "—",
                  style: TextStyle(
                    color: Color(0xff646464),
                    fontSize: 16,
                  ),
                ),
              ),
              right: 60,
              top: 130,
            ),
          ],
        ),
      ),
    );
  }
}
